package com.zgxt.demo.config;


import com.zgxt.demo.util.LoginInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

// 拦截器
@Configuration
public class MvcConfig implements WebMvcConfigurer {

    @Resource
    private StringRedisTemplate stringRedisTemplate;

    @Override
    public void addInterceptors(InterceptorRegistry registry){
        registry.addInterceptor(new LoginInterceptor(stringRedisTemplate)).excludePathPatterns(
                "/captcha.jpg",
                "/login",
                "/role",
                "/sseintoken",
                "/log",
                "/directory_data",
                "/second_directory_data",
                "/second_directory",
                "/parent_directory",
                "/admin_login",
                "/registerId",
                "/register",
                "/forget",
                "/addLog",
                "/food",
                "/foodlist",
                "/newtracelist",
                "/deleteLog",
                "/updateLog",
                "/queryDialogue",
                "/deleteDialogue",
                "/update_user",
                "/delete_user",
                "/query_users",
                "/admin_name",
                "/admin_password",
                "/secondDirectoryListAll",
                "/parentDirectoryListAll",
                "/s_directoryListAll",
                "/directoryListAll",
                "/updatesecond",
                "/updates_directory",
                "/updatedirectory",
                "/updateparent",
                "/deletedirectory",
                "/deletes_directory",
                "/deletesecond",
                "/deleteparent",
                "/adds_directory",
                "/addsecond",
                "/adddirectory",
                "/addparent",
                "/getParentBySid"
        );
    }
}
